package fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

/**
 * Created by Mr.xingkong on 2016/1/10.
 */
public class BaseFragment extends Fragment {

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init(view);
        loadDatas();
    }

    /**
     * 加载数据
     */
    public void loadDatas() {

    }

    /**
     * 初始化视图
     *
     * @param view
     */
    public void init(View view) {
    }

    /**
     * 静态工厂方法
     *
     * @param tClass
     * @param <T>
     * @return
     */
    public static <T extends BaseFragment> T newInstance(Class<T> tClass) {
        if (tClass != null) {
            try {
                T t = tClass.newInstance();
                return t;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

}
